# -*- coding:utf-8 -*-
"""
@文件 Events.py
@Time : 2025/2/25
@Author: zjj
@Des: fastapi 事件监听(暂时作废)
@Email: 1065377805@qq.com

"""
from fastapi import FastAPI

from database.mysql import register_mysql
from database.redis import redis_connect


def start_up(app: FastAPI) -> callable:
    async def app_up() -> None:
        # app启动完成时候触发
        print("程序启动啦")
        # 数据库启动
        await register_mysql(app)
        app.state.redis = await redis_connect()
        pass

    return app_up


def shutdown(app: FastAPI) -> callable:
    async def app_down() -> None:
        print("程序关闭啦")
        await app.state.redis.close()
        register_mysql(app).close()
    return app_down
